﻿@model CategoryArticleViewModel
@*
    根据分类显示相关的文章的面板
*@
@inject ArticleService _articleService
@inject CategoryService _categoryService

@{
    var articles = await _articleService.GetArticlesAsync(Model.Take, Model.Skip, Model.CategoryId, Model.OnlyRecommand);
    var category = await _categoryService.GetCategoryAsync(Model.CategoryId);
}


<div class="card">
    <div class="card-header">
        @category.Name
    </div>
    @if (articles.Any())
    {
    <ul class="list-group list-group-flush">
        @foreach (var item in articles)
        {
            <li class="list-group-item"><a asp-page="./Detail" asp-route-id="@item.Id" title="@item.Title">@(item.Title.Substring(0, 18, "..."))</a></li>
        }
    </ul>
    }
    else
    {
        <div class="text-center text-muted mt-3">@Model.EmptyDataText</div>
    }
    @if (Model.ShowMore)
    {
    <div class="card-footer">
        <a asp-page="./List" asp-route-categoryId="@category.Id">@Model.ShowMoreText</a>
    </div>
    }
</div>